var t = getApp();

Page({
    data: {
        goodsId: "",
        optionsId: "",
        total: "",
        tag: "",
        explain_title: "",
        explain_content: "",
        form: {
            member_name: "",
            member_card: ""
        },
        activityId: "",
        leader_id: ""
    },
    onLoad: function(t) {
        t.goodsId && this.setData({
            goodsId: t.goodsId
        }), t.optionsId && this.setData({
            optionsId: t.optionsId
        }), t.total && this.setData({
            total: t.total
        }), t.tag && this.setData({
            tag: t.tag
        }), t.activityId && this.setData({
            activityId: t.activityId
        }), t.leader_id && this.setData({
            leader_id: t.leader_id
        }), this._getexplain(), this._getMember();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    _getexplain: function() {
        var a = this, e = t.getNetAddresss("from.div-from.explain");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    explain_title: e.data.explain_title,
                    explain_content: e.data.explain_content
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getMember: function() {
        var a = this, e = t.getNetAddresss("from.div-from.getMemberInfo");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    "form.member_name": e.data.realname,
                    "form.member_card": e.data.idcard
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    memberNameinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.member_name": a
        });
    },
    membercardinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.member_card": a
        });
    },
    saveInfo: function() {
        var a = this;
        if (t._isTextEmpty(this.data.form.member_name)) wx.showToast({
            title: "请填写姓名！",
            icon: "none"
        }); else if (t._isTextEmpty(this.data.form.member_card)) wx.showToast({
            title: "请填写身份证号！",
            icon: "none"
        }); else {
            var e = this.data.goodsId, o = this.data.optionsId, i = this.data.total, n = this.data.tag, d = t.getNetAddresss("from.div-from.updateMemberInfo");
            d += "&member_name=" + this.data.form.member_name, d += "&member_card=" + this.data.form.member_card, 
            t._getNetWork({
                url: d,
                success: function(t) {
                    var d = t.data;
                    if (1 == d.result) {
                        if ("cart" == n) return void a.addCartReq(e, o, i);
                        if ("groupBuy_open" == n) return void wx.navigateTo({
                            url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&optionsId=0&goodsId=" + e + "&total=1&type=groupBuy_open&at_id=" + a.data.activityId
                        });
                        if ("groupBuy_join" == n) return void wx.navigateTo({
                            url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&optionsId=0&goodsId=" + e + "&total=1&type=groupBuy_join&at_id=" + this.data.activityId + "&leader_id=" + this.data.leader_id
                        });
                        if ("group" == n) return void wx.navigateTo({
                            url: "/packageA/detail_v2/detail_v2?id=" + a.data.activityId + "&name=group"
                        });
                        if ("delta" == n) return void wx.navigateBack({
                            delta: 1
                        });
                        wx.navigateTo({
                            url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=" + n + "&goodsId=" + e + "&optionsId=" + o + "&total=" + i
                        });
                    } else wx.showToast({
                        icon: "none",
                        title: d.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});